//
//  userAccountModel.swift
//  weiboLQ
//
//  Created by 半缘君 on 15/12/9.
//  Copyright © 2015年 banyuanjun.cn. All rights reserved.
//

import UIKit

class UserAccountModel: NSObject,NSCoding {

//    "access_token" = "2.00XFnoyCLATa4B548ed321cf1eD_9E";
//    "expires_in" = 157679999;
//    uid = 2730950923;
    

    /// 令牌
    var access_token: String?
    /// 过期时间
    var expires_in: NSTimeInterval = 0{
        
        didSet {
            expiresDate = NSDate(timeIntervalSinceNow: expires_in)
//            print(expiresDate)
        }
        
    }
    
    var expiresDate:NSDate?
    /// 用户ID
    var uid:String?

    init(dict:[String:AnyObject]){
        super.init()
        setValuesForKeysWithDictionary(dict)
//        expires_in.description
    }
    /// 大图
    var avatarLarge: String?
    /// 用户昵称
    var screenName:String?
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    override var description:String {
        
        return printClass(self.classForCoder)
    }
    
    //编码
    func encodeWithCoder(aCoder: NSCoder) {
//        aCoder.encodeObject(access_token, forKey: "access_token")
//        aCoder.encodeObject(uid, forKey: "uid")
//        aCoder.encodeObject(avatarLarge, forKey: "avatarLarge")
//        aCoder.encodeObject(screenName, forKey: "screenName")
        encodeObj(self, coder: aCoder)

    }
    //解码
    required init?(coder aDecoder: NSCoder) {
//        access_token = aDecoder.decodeObjectForKey("access_token") as! String
//        uid = aDecoder.decodeObjectForKey("uid") as! String
//        avatarLarge = aDecoder.decodeObjectForKey("avatarLarge") as! String
//        screenName  = aDecoder.decodeObjectForKey("screenName") as! String
//        
        super.init()
        decodeObj(self, coder: aDecoder)
        
    }

}
